package cn.wzy.controller;



import cn.wzy.annotation.AnPermission;
import cn.wzy.pojo.CarDetail;
import cn.wzy.results.ResponseResult;
import cn.wzy.service.CarDetailService;
import cn.wzy.vo.GoPageVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.annotation.TableName;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (CarDetail)表控制层
 *
 * @author makejava
 * @since 2023-01-24 10:49:09
 */
@RestController
@RequestMapping("carDetail")
@ApiOperation(value = "车辆详情管理")
@AnPermission(name = "车辆详情管理")
public class CarDetailController{
    /**
     * 服务对象
     */
    @Resource
    private CarDetailService carDetailService;
    
    /*
    * 查询分页
    * */
    @PostMapping("/page")
    @ApiOperation(value = "车辆详情分页查询",tags = "分页")
    @AnPermission(name = "车辆详情分页查询")
    public ResponseResult getCarDetailPage(@RequestBody GoPageVo goPageVo){
        return carDetailService.getCarDetailPage(goPageVo);
    }

    /*
    * 查询
    * */
    @GetMapping("/{id}")
    @AnPermission(name = "车辆详情id查询")
    @ApiOperation(value = "车辆详情id查询")
    public ResponseResult getCarDetail(@PathVariable("id") Long id){
        return carDetailService.getCarDetail(id);
    }

    /*
    * 新增和修改
    * */
    @PostMapping
    @AnPermission(name = "车辆详情修改或者添加")
    @ApiOperation(value = "车辆详情新增或者修改")
    public ResponseResult saveCarDetail(@RequestBody CarDetail carDetail){
        return carDetailService.saveCarDetail(carDetail);
    }

    /*
    * 删除
    * */
    @DeleteMapping("/{id}")
    @AnPermission(name = "id删除车辆详情")
    @ApiOperation(value = "删除车辆详情")
    public ResponseResult deleteCarDetail(@PathVariable("id") Long id){
        return carDetailService.deleteCarDetail(id);
    }


    /*
    * 批量删除
    * */
    @PatchMapping
    @AnPermission(name = "批量删除车辆详情")
    @ApiOperation(value = "批量删除车辆详情")
    public ResponseResult deleteCarDetailList(@RequestBody List<Long> ids){
        return carDetailService.deleteCarDetailList(ids);
    }

    /*
    * 资源查询
    * */
    @GetMapping("/carId")
    public ResponseResult getCarDetailResources(Long carId){
        return carDetailService.getCarDetailResources(carId);
    }

    /*
    * 资源保存
    * */
    @PostMapping("/save")
    public ResponseResult saveCarDetailResources(@RequestBody CarDetail carDetail){
        return carDetailService.saveCarDetailResources(carDetail);
    }


}

